<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01-路径操作-beginPath</title>
  <style media="screen">
    body {
      background-color: #000;
      text-align: center;
    }

    #c1 {
      background-color: #fff;
    }
  </style>
</head>

<body>
  <canvas id="c1" width="800" height="600"></canvas>

  <script>
    window.onload = function () {
      const oC = document.getElementById('c1')
      const gd = oC.getContext('2d')

      gd.moveTo(100, 100)
      gd.lineTo(300, 300)
      gd.strokeStyle = 'red'
      gd.stroke()

      // 注：结束之前的画笔状态，重新开始绘制路径
      gd.beginPath()
      gd.moveTo(300, 100)
      gd.lineTo(500, 300)
      gd.strokeStyle = 'yellow'
      gd.stroke()
    }
  </script>
</body>

</html>